export const style = {
  bgColor: '#ffffff',
  timeScaleColor: '#555',
  timeScaleBgColor: '#fff',
  scrollBarSliderColor: '#C9D1DB',
  scrollBarBorderColor: '#dddddd',
  textColor: '#2f4554'
}

export const dimension = {
  fontSize: 14,
  timeScaleWidth: 50,
  timeScaleHeightPerMinute: 20,
  timeScaleMarkLength0: 10,
  timeScaleMarkLength1: 20,
  entryListWidth: 250,
  scrollBarWidth: 20,
  timeLineWidth() {
    return this.timeScaleWidth + this.entryListWidth * 2
  }
}

export function getYByTime(t: number, t0: number, pageTime: number, h: number) {
  return ((t0 - t) * h) / pageTime + h
}

export const min5List: string[] = []

function minute2Str(m: number): string {
  const d = Math.floor(m / 1440)
  const h = Math.floor(m / 60) % 24
  const mm = m % 60
  let s = ''
  if (d > 0) {
    s = s + (d + 1) + ' '
  }
  s = s + h.toString().padStart(2, '0') + ':' + mm.toString().padStart(2, '0')
  return s
}

function generateMinutes() {
  const m1 = (48 * 60) / 5
  for (let m = 0; m <= m1; m++) {
    min5List.push(minute2Str(m * 5))
  }
}

function init() {
  generateMinutes()
}

init()
